* Table 1: Summary statistics: credit bureau sample vs. CPS
	use "$data/cb/clean_summary_statistics_credit_bureau_cps.dta", 	clear
	gsort cb_indpct
	cap file close myfile
	file open myfile using "$figures_tables/table1_summary_stats.txt", write replace
	file write myfile "\begin{threeparttable} \begin{tabular}{lcc} \toprule \toprule" _n "& Credit Bureau & CPS/BLS \\" _n "\midrule" _n
	local cb_wage : di %4.2f cb_avg_wage[1]
	local cps_wage : di %4.2f cps_full_avg_wage[1]
	file write myfile "\\ \textit{Wages} \\" _n
	file write myfile "Avg. hourly wage $<$ \\$30 & `cb_wage' & `cps_wage' \\" _n
	local cb_share_wage_lt30 : di %3.2f cb_share_wage_lt30[1]
	local cps_full_share_wage_lt30 : di %3.2f cps_full_share_wage_lt30[1]
	file write myfile "Share with wage $<$ \\$30 & `cb_share_wage_lt30' & `cps_full_share_wage_lt30' \\" _n
	file write myfile "\\ \textit{Industry} \\" _n
	foreach num of numlist 21(1)1 {
		local industry = naics2d_name[`num']
		local cb = cb_indpct[`num']/100
		local cb : di %3.2f `cb'
		if "`cb'" == "0.00" {
			local cb "$<$0.01"
		}
		local cps = cps_full_indpct[`num']/100
		local cps : di %3.2f `cps'
		if "`cps'" == "0.00" {
			local cps "$<$0.01"
		}
		file write myfile "`industry' & `cb' & `cps' \\" _n
	}
	local cb_firm : di %6.0fc cb_med_firm_size[1]
	local bls_firm = bls_med_firm_size[1]
	file write myfile "\\ \multicolumn{1}{l}{\textit{Size}} \\" _n "Median firm size & `cb_firm' & `bls_firm' \\" _n
	local cb_estab : di %4.0fc cb_avg_estab_size[1]
	local qcew_estab : di %4.0fc qcew_avg_estab_size[1]
	*file write myfile "Avg. establishment size & `cb_estab' & `qcew_estab' \\" _n
	file write myfile "\bottomrule \bottomrule \end{tabular}  \end{threeparttable}"
	file close myfile
	
	* Note: \footnotesize \textit{Notes:} Sample means for hourly jobs in credit bureau data from 2013 to 2023 and hourly workers in the CPS from 2013 to 2023. In column 1, the sample is restricted to establishments with any employment within a year of a treatment event with valid wage data. In column 2, the sample is restricted to employed individuals with valid wage data. \textit{Data sources:} Large credit bureau; CPS ORG.

	* Output numbers cited in text to a text file
	PrintEst `cb_wage' "cb_wage"	"" "%" 4.2f "$figures_tables/text"
	PrintEst `cps_wage' "cps_wage"	"" "%" 4.2f "$figures_tables/text"
	
	PrintEst 100*`cb_share_wage_lt30' "cb_share_wage_lt30"	"" "%" 4.0f "$figures_tables/text"
	PrintEst 100*`cps_full_share_wage_lt30' "cps_full_share_wage_lt30"	"" "%" 4.0f "$figures_tables/text"
